package hu.bme.mit.rifl.business.nodes;

import hu.bme.mit.rifl.business.base.WFElement;
import hu.bme.mit.rifl.business.shared.Coordinator;

/**
 * Worker node which books the transaction if the repository test returns an
 * "FEASIBLE" state. This step if performed simultaneously with the ServeOrder
 * step.
 */
public class BookTransaction extends WFElement {

	public BookTransaction(Coordinator coordinator) {
		super(coordinator, "BookTransaction");
	}

	@Override
	public void process() {
		this.order.setBooked(true);
		this.order.setStateCodes(6);
	}

	/**
	 * The overridden log result, since not the Order.state property is changed
	 * here, but the Order.isBooked.
	 */
	@Override
	protected void LogResult() {
		String log = this.getClass().getSimpleName() + ":Order with ID "
				+ this.order.getOrderID() + " BOOKED.";

		System.out.println(log);
		gui.log(log);
	}
}
